package team.seekers.table.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.BeanUtils;
import team.seekers.table.entity.Sysuser;
import team.seekers.table.entity.vo.User;
import team.seekers.table.mapper.SysuserMapper;
import team.seekers.table.service.SysuserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.sql.Wrapper;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author cbj
 * @since 2021-04-26
 */
@Service
public class SysuserServiceImpl extends ServiceImpl<SysuserMapper, Sysuser> implements SysuserService {

    @Override
    public User getUser(String userId) {
        QueryWrapper  wrapper = new QueryWrapper();
        wrapper.eq("id",userId);
        wrapper.select("username","password");
        Sysuser sysuser = baseMapper.selectOne(wrapper);
        User user = new User();
        user.setPassword(sysuser.getPassword());
        user.setUsername(sysuser.getUsername());
        return user;
    }

    @Override
    public void bind(User user) {
        Sysuser sysuser = new Sysuser();
        BeanUtils.copyProperties(user,sysuser);
        baseMapper.insert(sysuser);
    }
}
